package com.managementSystem.client.view;

import com.google.gwt.event.dom.client.HasClickHandlers;
import com.google.gwt.event.dom.client.HasKeyUpHandlers;
import com.managementSystem.client.presenter.LoginPresenter;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.DecoratorPanel;
import com.google.gwt.user.client.ui.DockPanel;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.HasValue;
import com.google.gwt.user.client.ui.PasswordTextBox;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.Widget;

public class LoginView extends Composite implements LoginPresenter.Display {
	public LoginView() {
		DecoratorPanel contentTableDecorator = new DecoratorPanel();
		initWidget(contentTableDecorator);
		contentTableDecorator.setWidth("100%");
		contentTableDecorator.setWidth("18em");
		
		contentTable = new FlexTable();
		contentTable.setWidth("100%");
		contentTable.getCellFormatter().addStyleName(0, 0, "contacts-ListContainer");
		contentTable.getCellFormatter().setWidth(0, 0, "100%");
		contentTable.getFlexCellFormatter().setVerticalAlignment(0, 0, DockPanel.ALIGN_MIDDLE);
	    nameField = new TextBox();
	    nameField.setFocus(true);
	    passwordField = new PasswordTextBox();
	    loginButton = new Button("Login");
	    registerButton = new Button("Register");
	    contentTable.getCellFormatter().addStyleName(0, 0, "contacts-ListMenu");
	    contentTable.setWidget(0, 0, nameField);
	    contentTable.setWidget(0, 1, passwordField);
	    contentTable.setWidget(0, 2, loginButton);
	    contentTable.setWidget(1, 2, registerButton);
	    contentTableDecorator.add(contentTable);
	    
	}
	private final Button loginButton;
	private final Button registerButton;
	private TextBox nameField;
	private PasswordTextBox passwordField;
	private final FlexTable contentTable;

	@Override
	public HasClickHandlers getLoginButton() {
		// TODO Auto-generated method stub
		return loginButton;
	}
	
	public HasClickHandlers getRegisterButton() {
		// TODO Auto-generated method stub
		return registerButton;
	}

	public HasValue<String> getUserName() {
		// TODO Auto-generated method stub
		return nameField;
	}

	public HasValue<String> getPassword() {
		// TODO Auto-generated method stub
		return passwordField;
	}

	public Widget asWidget() {
		return this;
	}

	@Override
	public HasKeyUpHandlers getPasswordComplete() {
		// TODO Auto-generated method stub
		return nameField;
	}

	@Override
	public HasKeyUpHandlers getUserNameComplete() {
		// TODO Auto-generated method stub
		return nameField;
	}
}
